package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.operation.cg.bean.CgBom;
import com.jy.adscm.operation.cg.bean.CgMaterial;
import com.jy.adscm.operation.cg.mapper.mysql.CgBomMapper;
import com.jy.adscm.operation.cg.mapper.mysql.CgMaterialMapper;
import com.jy.adscm.operation.mscyb.bean.JqbzSettingsInput;
import com.jy.adscm.operation.mscyb.bean.JqzzSettingInput;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqzzSettingInputMapper;
import com.jy.adscm.operation.mscyb.service.JqzzSettingInputService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.operation.purchase.bean.Purchasebom;
import com.jy.adscm.operation.purchase.mapper.mysql.PurchasebomMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-05-21
 */
@Service
public class JqzzSettingInputServiceImpl extends ServiceImpl<JqzzSettingInputMapper, JqzzSettingInput> implements JqzzSettingInputService {
    @Autowired
    CgMaterialMapper cgMaterialMapper;
    @Override
    public List<JqzzSettingInput> selectJqzzSettingInputByPid(String pid) {
        Wrapper<JqzzSettingInput> wrapper=new EntityWrapper<>();
        wrapper.eq("pid",pid);
        List<JqzzSettingInput> jqzzSettingInputs = super.selectList(wrapper);
        for (JqzzSettingInput jqzzSettingInput : jqzzSettingInputs) {
            CgMaterial cgMaterial = cgMaterialMapper.selectById(jqzzSettingInput.getCid());
            if (AdscmBaseUtils.getInstance().isNotEmpty(cgMaterial,null)){
                jqzzSettingInput.setName(cgMaterial);
                jqzzSettingInput.setCode(cgMaterial.getCode());
            }
        }
        return jqzzSettingInputs;
    }

    
}
